<template>
	<view>
		<image class="mytopbg" :style="{'height':'400rpx'}" :src="apifun.serveimg+'mywithbg.png'" mode="" />
		<page-head :title="'提现'" :bg="`transparent`" :headtype="2"></page-head>
		<view class="accoundye marginAuto">
			<view class="accoundye-title">我的钱包（元）</view>
			<view class="accoundye-moeny flex">
				<view class="accoundye-moenynum">
					<text style="font-size:24rpx;">￥</text>
					<text>{{ allmoeny }}</text>
				</view>
				<view class="accoundye-moenymx flex" @click="apifun.navigate('/pages/my/moenydetail')">
					<view style="font-size:28rpx;margin-top:18rpx;">明细</view>
					<uv-icon name="arrow-right" size="14" colo r="#666666"></uv-icon>
				</view>
			</view>
		</view>
		<view class="withmoney blockbg marginAuto">
			<view class="paymenttitle marginAuto">
				<view class="paymenttitle-title">*提现金额</view>
			</view>
			<view class="rechmoney marginAuto">
				<view class="rechmoney-b">￥</view>
				<view class="rechmoney-input">
					<input type="text" v-model="withnum" placeholder="请输入金额" />
				</view>
				<view class="rechmoney-btn" @click="withnum = allmoeny" style="color:#D72C29;">全部提现</view>
			</view>
		</view>
		<view class="withmoney blockbg marginAuto" >
			<view class="paymenttitle marginAuto">
				<view class="paymenttitle-title">*提现规则</view>
			</view>
			<view class="withtype">
				<view class="withrule marginAuto">
					<uv-parse :content="withrule"></uv-parse>
				</view>
				<!-- <view class="withtypeeach marginAuto">
					<view class="withtypel">
						<view class="withtypelimg">
							<image style="width: 60rpx;height:40rpx;margin-top:10rpx;"  src="@/static/icon/bank.png" mode="aspectFill"></image>
						</view>
						<view style="margin:10rpx 0 0 20rpx;color:#333333;font-size: 30rpx;">银行卡</view>
					</view>
					<view class="withtyper">
						<view class="techselect activepaytypeir">
							<u-icon class="marginAuto" name="checkmark" color="#333333" size="30"></u-icon>
						</view>
					</view>
				</view> -->
			</view>
		</view>
		<view class="marginAuto" style="width:600rpx;margin-top:90rpx;">
			<uv-button text="提现" @click="withenter()" :customStyle="{
				'background':'#1686F8',
				'color':'#ffffff',
				'font-size':'30rpx',
				'width':'600rpx',
				'height':'100rpx',
				'border-radius':'100rpx'
			}"></uv-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusheadheight:uni.getStorageSync('ClientRectTop')+uni.getStorageSync('ClientRectHeight'),
				apifun:this.apifun,
				usermsg:{},
				allmoeny:0,
				withnum:'',
				withrule:'',
			};
		},
		onLoad() {
			this.usermsg = uni.getStorageSync('usermsg');
			this.allmoeny = this.usermsg.money;
			this.getwithgzfun();
			this.getusermsgfun();
		},
		methods: {
			withenter(){
				let sendData = {
					amount:this.withnum
				};
				if(this.withnum <= 0 || this.withnum == ''){
					this.apifun.toast('提现金额不得小于0元')
					return false;
				};
				this.apifun.unirequest('/api/user/withdraw','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('提现成功');
						this.getusermsgfun();
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			getusermsgfun() {
				this.apifun.unirequest('/api/user/getUserInfo','post',{},(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.usermsg  = datas;
						this.allmoeny = datas.money;
						uni.setStorageSync('usermsg',datas);
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			getwithgzfun(){
				let sendData = {
					key:'提现规则'
				}
				this.apifun.unirequest('/api/index/getContent','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.withrule = datas;
					}else{
						this.apifun.toast(res.msg)
					}
				})
			}
		},
	};
</script>

<style scoped lang="scss">
	page{
		background:#F7F7F7;
	}
	.blockbg {
		width: 688rpx;
		padding: 24rpx 0;
		border-radius: 20rpx;
		background-color: #fff;
		margin-top: 20rpx;
	}
	.mytopbg{
		position: fixed;
		top: 0;
		left: 0;
		width:100vw;
	}
	// 
	.accoundye{
		position: relative;
		z-index: 150;
		width: 80%;
		padding:48rpx 0 36rpx;
		.accoundye-title{
			font-size: 28rpx;
			color: #333;
			margin-bottom: 18rpx;
		}
		.accoundye-moeny{
			font-size:60rpx;
			color: #333333;
			justify-content: space-between;
		}
	}
	// 提现金额
	.paymenttitle{
		position: relative;
		z-index: 10;
		width: 90%;
		padding: 20rpx 5%;
		line-height: 44rpx;
		color: #333;
		font-size:32rpx;
		border-bottom: 1px solid #F7F7F7;
		display:flex;
		justify-content: space-between;
	}
	.rechmoney{
		width: 80%;
		height:90rpx;
		line-height:90rpx;
		padding: 10rpx 5%;
		background:#F7F7F7;
		display: flex;
		margin-top:24rpx;
		.rechmoney-b{
			color: #333333;
			font-size:48rpx;
		}
		.rechmoney-input{
			width: 65%;
			height:90rpx;
			line-height:90rpx;
			margin-left: 20rpx;
			input{
				width: 100%;
				height:90rpx;
				line-height:90rpx;
				color: #333;
			}
		}
		.rechmoney-btn{
			color:#D72C29;
			font-size: 32rpx;
			width: 150rpx;
			text-align: center;
		}
	}
	/* 地址 */ 
	.withrule{
		width: 90%;
		font-size: 30rpx;
		color: #666666;
		line-height:60rpx;
		padding: 16rpx 0;
	}
	.withtypeeach{
		width: 90%;
		padding:24rpx 0;
		display: flex;
		justify-content: space-between;
		.withtypel{
			display: flex;
		}
		.techselect{
			display: flex;
			width: 40rpx;
			height: 40rpx;
			background-color:#F0F0F0;
			border-radius: 50%;
			margin-top: 10rpx;
		}
	}
	.activepaytypeir{
		border-color: #FDED1C !important;
		background-color: #FDED1C !important;
	}
	// btn
	.addsite-btn{
		position:fixed;
		bottom:0rpx;
		width: 90%;
		height:88rpx;
		padding: 6rpx 5% 20rpx;
		background-color:#fff;
	}
</style>